//package com.ifp.opengate.boot.filter;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.cloud.gateway.filter.GlobalFilter;
//import org.springframework.cloud.gateway.route.Route;
//import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
//import org.springframework.core.Ordered;
//import org.springframework.stereotype.Component;
//import org.springframework.web.server.ServerWebExchange;
//
//import com.ifp.core.log.Trace;
//import com.ifp.opengate.boot.utils.RedisUtils;
//
//import reactor.core.publisher.Mono;
//
///**
// * 项目名：ifp-gateway <br>
// * 包名：com.ifp.opengate.boot.filter <br>
// * 类名：IfpRateLimiterPathFilter <br>
// * 描述： 自定义实现简单接口地址过滤器限流
// *
// * @author liulx
// * @create 2021-06-23 17:49
// */
//@Component
//public class IfpRateLimiterPathFilter implements GlobalFilter, Ordered {
//
//    // @Value("${open.gate.ifpRateLimiterPath}")
//    // private String max;
//
//    private String maxKeyPrefix = "open.gate.ifpRateLimiterPath";
//
//    @Autowired
//    private RedisUtils redisUtils;
//
//    @Override
//    public Mono<Void> filter(ServerWebExchange serverWebExchange, GatewayFilterChain gatewayFilterChain) {
//        Trace.logInfo(Trace.MODULE_FILTER, "IfpRateLimiterPathFilter start filter....");
//        Route route = serverWebExchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR);
//        // Map<Object, Object> pathRateLimiterMap = redisUtils.hmget(maxKeyPrefix + route.getId());
//        // if (pathRateLimiterMap.isEmpty()) {
//        // return gatewayFilterChain.filter(serverWebExchange);
//        // }
//
//        // TODO
//        String rkey = maxKeyPrefix + route.getId();
//
//        // check(rkey);
//        return gatewayFilterChain.filter(serverWebExchange);
//
//    }
//
//    @Override
//    public int getOrder() {
//        return -7;
//    }
//
//}
